﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for datLop
/// </summary>
public class datLop
{
    public datLop()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    SqlCommand cmd;
    SqlDataReader dr;
    public List<entLop> getByMaKhoa(string maKhoa, string userid)
    {
        string constr = System.Configuration.ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
        SqlConnection sqlConnection = new SqlConnection(constr);
        sqlConnection.Open();
        cmd = new SqlCommand("sp_LopGetByMaKhoa", sqlConnection);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter[] sqla = new SqlParameter[2];
        sqla[0] = new SqlParameter("MaKhoa", DbType.String);
        sqla[1] = new SqlParameter("Userid", DbType.Int32);
        sqla[0].Value = maKhoa;
        sqla[1].Value = userid;
        cmd.Parameters.AddRange(sqla);
        dr = cmd.ExecuteReader();
        List<entLop> lst = new List<entLop>();
        entLop entL;
        while (dr.Read())
        {
            entL = new entLop();
            entL.MaLop = dr["malop"].ToString();
            entL.TenLop = dr["tenlop"].ToString();
            lst.Add(entL);
        }

        dr.Close();
        sqlConnection.Close();
        return lst;

    }
}